//从config中引入axios
import axios from "./config.js";

//登陆请求
export const Login = (username, password) =>
  axios({
    url: "/users/login",
    method: "post",
    data: {
      username,
      password
    }
  });

//获取登陆日志请求
export const getLoginlog = () => axios.get("/getloginlog");

//获取数据请求
export const getData = () => axios.get("/students/getstulist");

//获取权限菜单请求
export const getMenuList = () => axios.get("/permission/getMenuList");

//获取学员信息请求(采用动态传参方式)
export const getStuList = (params = {}) => {
  console.log(params)
  return axios({
    url: '/students/getstulist',
    params
  })
}

//获取班级列表请求
export const getClassList = () => axios.get("/students/getclasses")

//删除学员信息请求
export const delStu = sId => axios.get(`/students/delstu?sId=${sId}`);

//修改学员请求
// export const updateStu = axios({
//   url:"/students/updatestu",
//   method:"post",
//   data:{
//     sId:"",
//     token:"",
//     name:"",
//     age:"",
//     degree:"",
//     productUrl:"",
//     description:"",
//     headimgurl:""
//   }
// })
export const updateStu = payload => axios.post("/students/updatestu", payload);

//添加学员请求
export const addStu = payload => axios.post("/students/addstu", payload);

//搜索学员请求
export const searchStu = name => axios.get(`/students/searchstu?key=${name}`);

//获取验证码
export const getCaptcha = () => axios.get("/users/getCaptcha")

//刷新验证码
export const refreshCaptcha = () => axios.get("/users/refreshCaptcha")

//校验验证码
export const verifyCaptcha = (captch) => axios.get(`/users/verifyCaptcha?captcha=${captch}`)